/*package com.tunnel.common.compile;

import java.io.File;

import com.ajida.CmdUtil;

public class CompilerOnWindows {
	public static void main(String[] args) {
		try {
			File file = new File("");
			//base path
			String tunnel_common_root_path = file.getAbsolutePath();
			String disk_character = tunnel_common_root_path.split(":")[0]+":";
			
			
			
			//安装common包
			String result = CmdUtil.exec(new String[]{
				disk_character,
				"cd "+tunnel_common_root_path,
				"mvn clean install"
			});
			if(!result.contains("BUILD SUCCESS")){
				throw new Exception("tunnel-common mvn install failed");
			}
			
			//打包tunnel-client
			result = CmdUtil.exec(new String[]{
				disk_character,
				"cd "+tunnel_common_root_path,
				"cd ../tunnel-client",
				"mvn clean package"
			});
			if(!result.contains("BUILD SUCCESS")){
				throw new Exception("tunnel-client mvn package failed");
			}
			
			//打包tunnel-server
			result = CmdUtil.exec(new String[]{
				disk_character,
				"cd "+tunnel_common_root_path,
				"cd ../tunnel-server",
				"mvn clean package"
			});
			if(!result.contains("BUILD SUCCESS")){
				throw new Exception("tunnel-server mvn package failed");
			}
			
			//复制新的jar包
			try {
				CmdUtil.exec(new String[]{
					disk_character,
					"cd "+tunnel_common_root_path,
					"cd ../tunnel-client/tunnel-client/bin",
					"del /f /s /q tunnel-*.jar",
				});
			} catch (Exception e) {}
			CmdUtil.exec(new String[]{
				disk_character,
				"cd "+tunnel_common_root_path,
				"cd ../tunnel-common/target/",
				"copy \"tunnel-common-*.jar\" \""+tunnel_common_root_path+"/../tunnel-client/tunnel-client/bin\"",
				"cd "+tunnel_common_root_path,
				"cd ../tunnel-client/target/",
				"copy \"tunnel-client-*.jar\" \""+tunnel_common_root_path+"/../tunnel-client/tunnel-client/bin\""
			});
			
			try {
				CmdUtil.exec(new String[]{
					disk_character,
					"cd "+tunnel_common_root_path,
					"cd ../tunnel-server/tunnel-server/bin",
					"del /f /s /q tunnel-*.jar",
				});
			} catch (Exception e) {}
			CmdUtil.exec(new String[]{
				disk_character,
				"cd "+tunnel_common_root_path,
				"cd ../tunnel-common/target/",
				"copy \"tunnel-common-*.jar\" \""+tunnel_common_root_path+"/../tunnel-server/tunnel-server/bin\"",
				"cd "+tunnel_common_root_path,
				"cd ../tunnel-server/target/",
				"copy \"tunnel-server-*.jar\" \""+tunnel_common_root_path+"/../tunnel-server/tunnel-server/bin\""
			});
			
			//压缩zip
			try {
				CmdUtil.exec(new String[]{
					disk_character,
					"cd "+tunnel_common_root_path,
					"cd ../tunnel-client",
					"del /f /s /q tunnel-*.zip",
				});
			} catch (Exception e) {}
			ZipUtil.compressDir(new File(tunnel_common_root_path+"\\..\\tunnel-client\\tunnel-client"), tunnel_common_root_path+"\\..\\tunnel-client\\tunnel-client.zip");
			try {
				CmdUtil.exec(new String[]{
					disk_character,
					"cd "+tunnel_common_root_path,
					"cd ../tunnel-server",
					"del /f /s /q tunnel-*.zip",
				});
			} catch (Exception e) {}
			ZipUtil.compressDir(new File(tunnel_common_root_path+"\\..\\tunnel-server\\tunnel-server"), tunnel_common_root_path+"\\..\\tunnel-server\\tunnel-server.zip");
			
			//更新jar包到线上
//			updateServer(tunnel_common_root_path, "114.218.158.239");
//			updateServer(tunnel_common_root_path, "218.90.120.43");
			
			//更新jar包到内网
//			updateClient(tunnel_common_root_path, "192.168.199.45");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	public static void updateServer(String tunnel_common_root_path,String ip)throws Exception{
		System.out.println(">>>enter "+ip+" password:");
		Scanner sc = new Scanner(System.in);
		String password = sc.nextLine();
		sc.close();
		
		SSHConfig sshConfig = new SSHConfig(ip, "root", password);
		Connection connect = SSHUtil.connect(sshConfig);
		String pid = SSHUtil.grepPid("tunnel",10, connect);
		while(StringUtil.isNotEmpty(pid)){
			SSHUtil.exec(connect,"kill -9 "+pid,10);
			pid = SSHUtil.grepPid("tunnel",10, connect);
		}
		SSHUtil.exec(connect, "rm -rf /usr/local/tunnel-server/bin/tunnel-*.jar", 10);
		SSHUtil.uploadFile(tunnel_common_root_path+"\\..\\tunnel-server\\tunnel-server\\bin\\tunnel-server-0.1.jar", "/usr/local/tunnel-server/bin", connect);
		SSHUtil.uploadFile(tunnel_common_root_path+"\\..\\tunnel-server\\tunnel-server\\bin\\tunnel-common-0.1.jar", "/usr/local/tunnel-server/bin", connect);
		SSHUtil.exec(connect,new String[]{
			"cd /usr/local/tunnel-server",
			"./start.sh '/usr/local/tunnel-server/sys.properties'"
		},10,false);
	}
	
	public static void updateClient(String tunnel_common_root_path,String ip)throws Exception{
		System.out.println(">>>enter "+ip+" password:");
		Scanner sc = new Scanner(System.in);
		String password = sc.nextLine();
		sc.close();
		
		SSHConfig sshConfig = new SSHConfig(ip, "root", password);
		Connection connect = SSHUtil.connect(sshConfig);
		String pid = SSHUtil.grepPid("tunnel",10, connect);
		while(StringUtil.isNotEmpty(pid)){
			SSHUtil.exec(connect,"kill -9 "+pid,10);
			pid = SSHUtil.grepPid("tunnel",10, connect);
		}
		SSHUtil.exec(connect, "rm -rf /usr/local/tunnel-client/bin/tunnel-*.jar", 10);
		SSHUtil.uploadFile(tunnel_common_root_path+"\\..\\tunnel-client\\tunnel-client\\bin\\tunnel-client-0.1.jar", "/usr/local/tunnel-client/bin", connect);
		SSHUtil.uploadFile(tunnel_common_root_path+"\\..\\tunnel-client\\tunnel-client\\bin\\tunnel-common-0.1.jar", "/usr/local/tunnel-client/bin", connect);
		SSHUtil.exec(connect,new String[]{
				"cd /usr/local/tunnel-client",
				"./start.sh '/usr/local/tunnel-client/sys.properties'"
			},10,false);
	}
}
*/